package com.hrt.web.product.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.hrt.base.BaseDaoImpl;
import com.hrt.bean.GiftDetail;
import com.hrt.web.product.dao.GiftDetailDao;
@Repository
public class GiftDetailDaoWebImpl extends BaseDaoImpl<GiftDetail> implements GiftDetailDao{

	@SuppressWarnings("unchecked")
	@Override
	/**根据礼品基本信息的id找到礼品规格的id集合*/
	public List<String> getDetailIdforId(Long id) {
		String hql = "select DISTINCT detail.color from GiftDetail detail where detail.giftId='"+id+"' and detail.isdelete=0 and detail.ispush=1";
		return getHibernateTemplate().find(hql);
	}

	@SuppressWarnings("unchecked")
	@Override
	/**根据礼品基本信息的id和color找到礼品规格集合*/
	public List<GiftDetail> getColorAndGI(Long giftId, String color) {
		String hql = "select detail from GiftDetail detail where detail.giftId='"+giftId+"' and detail.isdelete=0 and detail.ispush=1 and detail.color='"+color+"'";
		return getHibernateTemplate().find(hql);
	}

	@SuppressWarnings("unchecked")
	@Override
	/**根据礼品基本信息的id找到礼品规格的集合*/
	public List<GiftDetail> getDetailByGI(Long giftId) {
		String hql = "select detail from GiftDetail detail where detail.giftId='"+giftId+"' and detail.isdelete=0 and detail.ispush=1";
		return getHibernateTemplate().find(hql);
	}

	@Override
	/**根据礼品基本信息的id和gdName找到礼品规格集合*/
	public GiftDetail getByGiftIdAndName(Long giftId, String gdName) {
		String hql = "select detail from GiftDetail detail where detail.giftId='"+giftId+"' and detail.isdelete=0 and detail.ispush=1 and detail.gdName='"+gdName+"'";
		return (GiftDetail) getHibernateTemplate().find(hql).get(0);
	}

}
